﻿using System;
using System.Windows.Forms;
using Elkomp;

namespace MedicinskiUslugi {

	public partial class frmEEdinici : FormaBrowse {

		public frmEEdinici() {
			InitializeComponent();
			btnOk.Visible = false;
		}

		public frmEEdinici( bool zoom ) {
			InitializeComponent();
			btnOk.Visible = true;
			zoom = true;
		}

		private void SelcectionCHanged( object sender, EventArgs e ) {
			if ( this.tblEEdinicaGrid.CurrentRow != null ) {
				dr = this.medicinskiUslugiDataSet.tblEEdinica[this.tblEEdinicaGrid.CurrentRow.Index];
			}
		}

		public override void NovZapis( object sender, EventArgs e ) {
			this.tblEEdinicaGrid.Insert();
			base.NovZapis( sender, e );
		}

		public override void IzmeniZapis( object sender, EventArgs e ) {
			this.tblEEdinicaGrid.Edit();
			base.IzmeniZapis( sender, e );
		}

		private void frmEEdinici_Load( object sender, EventArgs e ) {
			Navigator.BindingSource = tblEEdinicaBindingSource;
			this.tblEEdinicaTableAdapter.Fill( this.medicinskiUslugiDataSet.tblEEdinica );
		}

		private void btnPrebaraj_Click( object sender, EventArgs e ) {
			this.tblEEdinicaTableAdapter.Fill( this.medicinskiUslugiDataSet.tblEEdinica );
			this.tblEEdinicaBindingSource.Filter = " Sifra LIKE '%" + Sifra.Text + "%' and Naziv LIKE '%" + Naziv.Text + "%'";
		}

		public override void IzbrisiZapis( object sender, EventArgs e ) {
			if ( this.tblEEdinicaGrid.CurrentRow != null ) {
				DialogResult opc;
				opc = MessageBox.Show( "Дали сте сигурни ?", "", MessageBoxButtons.YesNo, MessageBoxIcon.Question );
				if ( opc == DialogResult.Yes ) {
					this.tblEEdinicaGrid.Rows.Remove( tblEEdinicaGrid.CurrentRow );
					this.tableAdapterManager.UpdateAll( this.medicinskiUslugiDataSet );
				}
			}

			base.IzbrisiZapis( sender, e );
		}

		private void tblEEdinicaGrid_DataInsert() {
			this.tblEEdinicaTableAdapter.Fill( this.medicinskiUslugiDataSet.tblEEdinica );
		}
	}
}